Skip to content

✨ Add TypedInformer source#3520

Open
cezarsa wants to merge 1 commit into
kubernetes-sigs:mainfrom
cezarsa:ce-typed-informer
Open

✨ Add TypedInformer source#3520
cezarsa wants to merge 1 commit into
kubernetes-sigs:mainfrom
cezarsa:ce-typed-informer

Conversation

@cezarsa
Copy link
Copy Markdown

@cezarsa cezarsa commented May 15, 2026

This PR mimics the existing pattern of having a typed version of each source. This small change would help users avoid having to write their own version of TypedInformer.

For an example of a use-case, see: https://github.com/kubernetes-sigs/aws-load-balancer-controller/pull/4678/changes#diff-aeaa3ed265c13311667100ad572f071fc3928d07227e8320322116bfee2a0e90

This mimicks the existing pattern of having a typed version of each
source.
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: cezarsa
Once this PR has been reviewed and has the lgtm label, please assign joelanford for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 15, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @cezarsa!

It looks like this is your first PR to kubernetes-sigs/controller-runtime 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/controller-runtime has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 15, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @cezarsa. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 15, 2026
@alvaroaleman
Copy link
Copy Markdown
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 16, 2026

// EventHandler adapts a handler.EventHandler interface to a cache.ResourceEventHandler interface.
type EventHandler[object client.Object, request comparable] struct {
type EventHandler[object any, request comparable] struct {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being changed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the definition of handler.TypedEventHandler doesn't constrain the object and allows any, neither does any of the source generic types. Without that change, the TypedInformer definition would also have to be constrained to client.Object which wouldn't be desirable, and it would limit its use.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would it limit its use? What use-case exists where TypedInformer is typed to something that does not satisfy client.Object?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one here: https://github.com/kubernetes-sigs/aws-load-balancer-controller/pull/4678/changes#diff-8ce64d4b8a4655d407ba70bf654823f4f4d4e7a7036da24f85d1b1fe99bf6aebR281

It's possible to use cache.SharedIndexInformer{}.SetTransform() to transform the original object into an instance that doesn't satisfy client.Object.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@cezarsa: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-controller-runtime-apidiff b46bfde link false /test pull-controller-runtime-apidiff

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants